import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { PackageVO, PackageForm, PackageQuery } from '@/api/credit/package/types';

/**
 * 查询养卡套餐列表
 * @param query
 * @returns {*}
 */

export const listPackage = (query?: PackageQuery): AxiosPromise<PackageVO[]> => {
  return request({
    url: '/credit/package/list',
    method: 'get',
    params: query
  });
};


export const listNoPagePackage = (query?: PackageQuery): AxiosPromise<PackageVO[]> => {
  return request({
    url: '/credit/package/noPage/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询养卡套餐详细
 * @param id
 */
export const getPackage = (id: string | number): AxiosPromise<PackageVO> => {
  return request({
    url: '/credit/package/' + id,
    method: 'get'
  });
};

/**
 * 新增养卡套餐
 * @param data
 */
export const addPackage = (data: PackageForm) => {
  return request({
    url: '/credit/package',
    method: 'post',
    data: data
  });
};

/**
 * 修改养卡套餐
 * @param data
 */
export const updatePackage = (data: PackageForm) => {
  return request({
    url: '/credit/package',
    method: 'put',
    data: data
  });
};

/**
 * 删除养卡套餐
 * @param id
 */
export const delPackage = (id: string | number | Array<string | number>) => {
  return request({
    url: '/credit/package/' + id,
    method: 'delete'
  });
};
